var tab = document.querySelector(".tab")
console.log(tab);
var lis = tab.querySelectorAll("li")
var items = document.querySelectorAll(".item")
var homeshow = document.querySelector(".homeshow")
var disno = document.querySelector(".disno")
var two = document.querySelector(".two")
var spans = two.querySelectorAll("span")
// console.log(spans);
var item_two = document.querySelector(".item-two")
var showtwo = item_two.querySelectorAll("span")
// var i=0
for (var i = 0; i < lis.length; i++) {
    lis[i].setAttribute("index", i)
    lis[i].onclick = function () {
        var index = this.getAttribute("index");
        for (var j = 0; j < lis.length; j++) {
            lis[j].className = ""
        }
        // console.log(typeof(index));
        lis[index].className = "current"
        var tab_two = document.querySelector(".tab-two")
        if (index === "1") {
            tab_two.style.display = "block"
        } else {
            tab_two.style.display = "none"
            disno.style.display = "block"
        }
        for (var j = 0; j < items.length; j++) {
            items[j].style.display = "none"
        }
        homeshow.style.display = "none"
        items[index].style.display = "block"

    }
}

// 日常下的二级菜单

// console.log(showtwo);
for (var i = 0; i < spans.length; i++) {
    spans[i].setAttribute("index", i)
    spans[i].onclick = function () {
        var index = this.getAttribute("index");
        for (var j = 0; j < spans.length; j++) {
            spans[j].className = ""
        }
        spans[index].className = "text"
        for (var j = 0; j < showtwo.length; j++) {
            showtwo[j].style.display = "none"
        }
        showtwo[index].style.display = "block"
        // disno.style.display="none"
    }
}   

function esc(){
    window.location.href="login.html"
}
// disno.style.display="block"
// 判断是否登录如果未登录则跳转到登陆界面
function login() {
    var userid = localStorage.getItem("userid")
    // var string=toString(userid)
    // console.log(typeof(userid));
    var flag=true
    if (userid ==="") {
        flag=false
        window.location.href = "login.html"
        
    }else{
        flag=true
    }
    // console.log(1);
}
login()
// 判断登录的权限如果为0则全部显示
